mutate(lbl = case_when(y == "y1" ~ "Party A",
y == "y2" ~ "Party B",
y == "y3" ~ "Party C")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "8", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF", "#00BA38"), labels = c("Party A", "Party B", "Party C")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
xlim(0,4) + ylim(0,2)
p.labs
# Combine the plots
fig.ill <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8, p.labs,
label.x = 0,
legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
#fig.ill <- annotate_figure(fig.ill, bottom = textGrob("Position", gp = gpar(cex = 1.3)))
fig.ill
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
xlim(0,4) + ylim(0,2)
p.labs
# Combine the plots
fig.ill <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8, p.labs,
label.x = 0,
legend="none",
ncol=2,
nrow=5,
common.legend = TRUE)
fig.ill
# Clear the space
rm(list = ls())
# Set theme of figures
personal_theme = theme_classic() + theme(axis.line.y = element_blank(), axis.text.y = element_blank(), axis.ticks.y = element_blank())
# Set the seed for reproducibility
set.seed(123)
### Panel 1:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = 1.5) |> round(digits = 0)
data1 <- data.frame(y1, y2)
p.1 <- pivot_longer(data1, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "1", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 2:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 2) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 2) |> round(digits = 0)
data2 <- data.frame(y1, y2)
p.2 <- pivot_longer(data2, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "2", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 3:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 2, sd = 2) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 8, sd = 2) |> round(digits = 0)
data3 <- data.frame(y1, y2)
p.3 <- pivot_longer(data3, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "3", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 4:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = .5) |> round(digits = 0)
data4 <- data.frame(y1, y2)
p.4 <- pivot_longer(data4, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "4", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 5:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 3) |> round(digits = 0)
data5 <- data.frame(y1, y2)
p.5 <- pivot_longer(data5, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "5", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 6:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 1.3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 1.3) |> round(digits = 0)
data6 <- data.frame(y1, y2)
p.6 <- pivot_longer(data6, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "6", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 7:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 3, sd = 3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = 0.5) |> round(digits = 0)
y3 <- rtruncnorm(1000, a=0, b=10, mean = 7, sd = 1) |> round(digits = 0)
data7 <- data.frame(y1, y2, y3)
p.7 <- pivot_longer(data7, c("y1", "y2", "y3"), names_to = "y", values_to = "val") |>
mutate(lbl = case_when(y == "y1" ~ "Party A",
y == "y2" ~ "Party B",
y == "y3" ~ "Party C")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "7", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF", "#00BA38"), labels = c("Party A", "Party B", "Party C")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 8:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 2, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = .5) |> round(digits = 0)
y3 <- rtruncnorm(1000, a=0, b=10, mean = 8, sd = .5) |> round(digits = 0)
data8 <- data.frame(y1, y2, y3)
p.8 <- pivot_longer(data8, c("y1", "y2", "y3"), names_to = "y", values_to = "val") |>
mutate(lbl = case_when(y == "y1" ~ "Party A",
y == "y2" ~ "Party B",
y == "y3" ~ "Party C")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "8", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF", "#00BA38"), labels = c("Party A", "Party B", "Party C")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
# Combine the plots
fig.ill <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8,
label.x = 0,
#                     legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
fig.ill
# Clear the space
rm(list = ls())
# Set theme of figures
personal_theme = theme_classic() + theme(axis.line.y = element_blank(), axis.text.y = element_blank(), axis.ticks.y = element_blank())
# Set the seed for reproducibility
set.seed(123)
### Panel 1:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = 1.5) |> round(digits = 0)
data1 <- data.frame(y1, y2)
p.1 <- pivot_longer(data1, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "1", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 2:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 2) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 2) |> round(digits = 0)
data2 <- data.frame(y1, y2)
p.2 <- pivot_longer(data2, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "2", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 3:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 2, sd = 2) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 8, sd = 2) |> round(digits = 0)
data3 <- data.frame(y1, y2)
p.3 <- pivot_longer(data3, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "3", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 4:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = .5) |> round(digits = 0)
data4 <- data.frame(y1, y2)
p.4 <- pivot_longer(data4, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "4", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 5:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 3) |> round(digits = 0)
data5 <- data.frame(y1, y2)
p.5 <- pivot_longer(data5, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "5", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 6:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 4, sd = 1.3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 6, sd = 1.3) |> round(digits = 0)
data6 <- data.frame(y1, y2)
p.6 <- pivot_longer(data6, c("y1", "y2"), names_to = "y", values_to = "val") |>
mutate(lbl = if_else(y == "y1", "Party A", "Party B")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "6", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF"), labels = c("Party A", "Party B")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 7:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 3, sd = 3) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = 0.5) |> round(digits = 0)
y3 <- rtruncnorm(1000, a=0, b=10, mean = 7, sd = 1) |> round(digits = 0)
data7 <- data.frame(y1, y2, y3)
p.7 <- pivot_longer(data7, c("y1", "y2", "y3"), names_to = "y", values_to = "val") |>
mutate(lbl = case_when(y == "y1" ~ "Party A",
y == "y2" ~ "Party B",
y == "y3" ~ "Party C")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "7", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF", "#00BA38"), labels = c("Party A", "Party B", "Party C")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Panel 8:
y1 <- rtruncnorm(1000, a=0, b=10, mean = 2, sd = .5) |> round(digits = 0)
y2 <- rtruncnorm(1000, a=0, b=10, mean = 5, sd = .5) |> round(digits = 0)
y3 <- rtruncnorm(1000, a=0, b=10, mean = 8, sd = .5) |> round(digits = 0)
data8 <- data.frame(y1, y2, y3)
p.8 <- pivot_longer(data8, c("y1", "y2", "y3"), names_to = "y", values_to = "val") |>
mutate(lbl = case_when(y == "y1" ~ "Party A",
y == "y2" ~ "Party B",
y == "y3" ~ "Party C")) |>
ggplot(aes(val, fill=lbl)) + geom_histogram(alpha=0.5, binwidth=1,  position = "identity") +
labs(title = "8", x= "", y="") +
scale_fill_manual(values = c("#F8766D", "#619CFF", "#00BA38"), labels = c("Party A", "Party B", "Party C")) +
ylim(0, 700) +
scale_x_continuous(limits = c(0,10), breaks = c(0, 2.5, 5, 7.5, 10), labels = c('0', '2.5', '5', '7.5', '10')) +
personal_theme
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
xlim(0,4) + ylim(0,2)
p.labs
fig.ill <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8, p.labs,
label.x = 0,
legend="none",
ncol=2,
nrow=5,
widths = c(1,1,1,1,2),
common.legend = TRUE)
#fig.ill <- annotate_figure(fig.ill, bottom = textGrob("Position", gp = gpar(cex = 1.3)))
fig.ill
fig.ill
top <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8,
label.x = 0,
legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2)
fig.ill
p.labs
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
#  xlim(0,4) + ylim(0,2)
xlim(1,3) + ylim(1,1)
p.labs
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
#  xlim(0,4) + ylim(0,2)
xlim(.9,3.1) + ylim(1,1)
p.labs
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
#  xlim(0,4) + ylim(0,2)
xlim(0,4) + ylim(1,1)
p.labs
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
#  xlim(0,4) + ylim(0,2)
xlim(0,4) + ylim(1,1) +
theme(plot.margin = margin(0,0,0,0))
p.labs
top <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8,
label.x = 0,
legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2)
fig.ill
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(3,1))
fig.ill
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(5,1))
fig.ill
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(7,1))
fig.ill
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(9,1))
fig.ill
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 5) +
xlim(0,4) + ylim(1,1) +
theme(plot.margin = margin(0,0,0,0))
p.labs
top <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8,
label.x = 0,
legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(9,1))
fig.ill
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(10,1))
fig.ill
pdf("illustrations.pdf")
fig.ill
dev.off()
### Label the parties by color
p.labs <- ggplot() +
theme_void() +
annotate("text", x = 1:3, y = 1, label = c('Party A', 'Party B', 'Party C'), colour = c("#F8766D", "#619CFF", "#00BA38"), size = 7) +
xlim(0,4) + ylim(1,1) +
theme(plot.margin = margin(0,0,0,0))
p.labs
### Combine the plots
top <- ggarrange(p.1, p.2, p.3, p.4, p.5, p.6, p.7, p.8,
label.x = 0,
legend="none",
ncol=2,
nrow=4,
common.legend = TRUE)
fig.ill <- ggarrange(top, p.labs,
ncol=1,
nrow=2,
heights = c(10,1))
fig.ill
### Save the plot
pdf("illustrations.pdf")
fig.ill
dev.off()
# Clear the space
rm(list = ls())
?lmer
?glmer
library(ggplot2)
library(texreg)
library(marginaleffects)
################################################################################
# Clear the space
rm(list = ls())
setwd("C:/Users/williamslaro/OneDrive - University of Missouri/Documents/Research/Projects/Random Projects/Strategic Ambiguity/JEPOP/Revision/Reproduction")
# Read in the RData which contains the two datasets
load("SW.RData")
################################################################################
################################## Summary Statistics ##########################
################################################################################
# Individual-level data
summary(data.ind[, c('votefor', 'dist', 'pdf', 'scoreA', 'brand', 'prtycore', 'like')])
sd(data.ind$votefor, na.rm = T)
sd(data.ind$dist, na.rm = T)
sd(data.ind$pdf, na.rm = T)
sd(data.ind$scoreA, na.rm = T)
sd(data.ind$brand, na.rm = T)
sd(data.ind$prtycore, na.rm = T)
sd(data.ind$like, na.rm = T)
# Party-level data
summary(data.party[, c('vote_cses', 'scoreA.x', 'brand', 'pdf', 'xtrm', 'enp', 'dist2')])
sd(data.party$vote_cses, na.rm = T)
sd(data.party$scoreA.x, na.rm = T)
sd(data.party$brand, na.rm = T)
sd(data.party$pdf, na.rm = T)
sd(data.party$xtrm, na.rm = T)
sd(data.party$enp, na.rm = T)
sd(data.party$dist2, na.rm = T)
################################################################################
################################## Models ######################################
################################################################################
### Manuscript
# Model 1
m1 <- lmer(dist ~ brand*pdf + prtycore + like + adifp + (1| ccses), data = data.ind)
library(lme4)
# Model 1
m1 <- lmer(dist ~ brand*pdf + prtycore + like + adifp + (1| ccses), data = data.ind)
summary(m1)
m1.plot.a <- plot_comparisons(m1,
variable = list(brand="sd"),
condition = "pdf", re.form = NA) +
labs(x = "Ideological Overlap", y = "Perceived Distance") +
geom_hline(yintercept=0,linetype=2) +
geom_rug(aes(x=pdf), data=data.ind, sides="b") +
theme_classic()
m1.plot.a
library(ggExtra)
install.packages("ggExtra")
library(ggExtra)
library(ggplot2)
set.seed(30)
df1 <- data.frame(x = rnorm(500, 50, 10), y = runif(500, 0, 50))
p1 <- ggplot(df1, aes(x, y)) + geom_point() + theme_bw()
p1
ggMarginal(p1)
p1 <- ggplot(df1, aes(x, y)) + geom_line() + theme_bw()
p1
ggMarginal(p1)
p1 <- ggplot(df1, aes(x, y)) + geom_point() + geom_line() + theme_bw()
p1
ggMarginal(p1)
p1 <- ggplot(df1, aes(x, y)) + geom_point(alpha = 0.1) + geom_line() + theme_bw()
p1
ggMarginal(p1)
p1 <- ggplot(df1, aes(x, y)) + geom_point(alpha = 0) + geom_line() + theme_bw()
p1
ggMarginal(p1)
ggMarginal(p1, type = "histogram")
ggMarginal(p1, margins = "x", type = "histogram")
ggMarginal(p1, margins = "x", type = "density")
ggMarginal(p1, margins = "x", type = "boxplot")
ggMarginal(p1, margins = "x", type = "histogram", size = 5)
ggMarginal(p1, margins = "x", type = "histogram", size = 10)
m1.plot.a
m1.plot.a <- plot_comparisons(m1,
variable = list(brand="sd"),
condition = "pdf", re.form = NA) +
labs(x = "Ideological Overlap", y = "Perceived Distance") +
geom_hline(yintercept=0,linetype=2) +
#  geom_rug(aes(x=pdf), data=data.ind, sides="b") +
theme_classic()
m1.plot.a
m1.plot.a <- plot_comparisons(m1,
variable = list(brand="sd"),
condition = "pdf", re.form = NA) +
labs(x = "Ideological Overlap", y = "Perceived Distance") +
geom_hline(yintercept=0,linetype=2) +
geom_point(alpha = 0) +
#  geom_rug(aes(x=pdf), data=data.ind, sides="b") +
theme_classic()
m1.plot.a
ggMarginal(m1.plot.a, margins = "x", type = "density")
m1.plot.a <- plot_comparisons(m1,
variable = list(brand="sd"),
condition = "pdf", re.form = NA) +
labs(x = "Ideological Overlap", y = "Perceived Distance") +
geom_hline(yintercept=0,linetype=2) +
geom_point(alpha = 0) +
#  geom_rug(aes(x=pdf), data=data.ind, sides="b") +
theme_classic()
m1.plot.a
ggMarginal(m1.plot.a, margins = "x", type = "histogram")
m1.plot.a <- plot_comparisons(m1,
variable = list(brand="sd"),
condition = "pdf", re.form = NA) +
labs(x = "Ideological Overlap", y = "Perceived Distance") +
geom_hline(yintercept=0,linetype=2) +
geom_point(alpha = 0) +
geom_density(aes(x=pdf), data=data.ind, sides="b") +
theme_classic()
m1.plot.a
